<?php
define('ROOT_PATH', substr(dirname(__FILE__),0,strlen(dirname(__FILE__))-strlen('service')-1));
include(ROOT_PATH . '/eccore/ecmall.php');

require(ROOT_PATH . '/eccore/model/model.base.php');   //模型基础类
/* 定义配置信息 */
ecm_define(ROOT_PATH . '/data/config.inc.php');
ecm_define(ROOT_PATH . '/data/settings.inc.php');
/* 环境 */
define('CHARSET', 'utf-8');
require_once '../baidupush/sdk.php';
include_once 'mobilecommon.php';
include_once 'haulCommon.php';
include_once 'landcarriageService.php';
 
 
 //----------------------------------------------------------------------------------
$result = JSON(array('status'=>'参数错误'));
$status=0;
$result=!empty($_POST['result'])?$_POST['result']:"";
$returnurl=!empty($_POST['returnurl'])?$_POST['returnurl']:"";
//smsSend('短信验证码：123444','15192546965');
try{
	$p = $_POST['p']?$_POST['p']:'';
	if(empty($_POST['alert']))
	{
		$p=decrypt($p);
	}

	$p=str_replace('\"','"',$p);
	$p=str_replace("\r",'',$p);
	$p=str_replace("\n",'\n',$p);
	
	$pars=json_decode($p);
	
	if(empty($pars)){
		throw new Exception("未取得参数信息");
	}
switch (strtolower($pars->op)) {
		case 'newjsbill':   //创建集港
			$result=createJGWayBill($pars);
			break;
		case 'newsgbill':   //创建疏港
			$result=createSGWayBill($pars);
			break;
		case 'pushmsg':   //推送消息
			$result=pushMessage($pars);
			break;
			//通訊錄
		case 'checkbox':    //验箱
			$result=checkbox($pars);
			break;
		default:
			break;
	}
}
catch (Exception $exp){
	$status1=$exp->getMessage();
	$result=JSONResult($status,$status1,$pars);
}
if($result=='alert'||!empty($returnurl)){
	if(!empty($returnurl)){
		echo "<form style='display:none;' id='form1' name='form1' method='post' action='$returnurl?XDEBUG_SESSION_START=ECLIPSE_DBGP'>
              <input name='result' type='text' value='{$result}' />
              <input name='r' type='text' value='".$result."'/>
            </form>
            <script type='text/javascript'>function load_submit(){document.form1.submit()}load_submit();</script>";
	}
	else{
		echo('<script>alert(\''.$result.'\');</script>');
	}
}
else{
	header("content-type:text/html;charset=utf-8");
	if(empty($_POST['alert']))
	{
		echo encrypt($result);
	}
	else
	{
		echo $result;
	}
	//echo ($result);
}

